<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Delete Broadcaster</title>
<style type="text/css">
p {font-family:Arial, Helvetica, sans-serif; font-size: 11px;}
select{ width: 150px;
}
</style>

<script type="text/javascript" src="loadbroad.js">
</script>
<script>
var http_request;
function toserver(f) {
            var sbroad = "http://silo.cs.indiana.edu:13795/servlet/DeleteBroadCasterServlet?nym=home&broadcasters=";

           var r = new Array();
          for (var i = 0; i < f.friends.options.length; i++){
          if (f.friends.options[i].selected)
  		r[i] = f.friends.options[i].value;
    
  	 if(r[i]!=null) {
	    	var slength = r[i].length;
	    	r[i] = r[i].slice(1, slength-1);
	    	var sbroad = sbroad+r[i]+",";
    	  	}
	    }
	    sblength = sbroad.length;
            sbroad = sbroad.slice(0, sblength-1); 
	   alert(sbroad);
 	   loadXMLDoc2(sbroad);
       // var url = "loadXMLDoc(\"http://silo.cs.indiana.edu:13795/servlet/DeleteBroadCasterServlet?\");";



}

function callback2()
	{	
	      try{
                 if(http_request.readyState == 4)
		   {
                                    
                      if(http_request.status == 200) {
				        alert(http_request.responseText);
					var items = [];	
					var b1 = http_request.responseXML.getElementsByTagName('valid');
					var valid = b1.item(0).firstChild.nodeValue;
					if(valid == 1)
						alert("Success");
					else
						alert("Failure");
 	                               }
                       
		    else  
                        alert("There was a problem with the request");		
	  	          
               }
             }

    	catch( e )
     	   { alert("Catch Error:" + e);		
       	   }

	}

function loadXMLDoc2(url_var) {

        if (window.XMLHttpRequest)
        {
          http_request = new XMLHttpRequest();
          http_request.onreadystatechange = callback2;
          http_request.open('GET', url_var, true);
          http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
          http_request.send("FDIC");
//          http_request.onreadystatechange = callback2;
                      //initialize the request
     }


 else if(window.ActiveXObject){
          //Create our RequestObject
          http_request = new ActiveXObject("Microsoft.XMLHTTP");
          if(http_request){
                http_request.onreadystatechange = function() { callback2(http_request); };
                http_request.open('GET', url_var, true);
                http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                http_request.send("FDIC");                      //initialize the request
                }
          }


        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
}

</script>
</head>

<body>
<form name="f">
  <p><strong>Select Broadcasters to Delete</strong></p>
  <p><strong> 
    <select name="friends" size="5" multiple="multiple" id="friends" style="width: 150;">
    </select>
    </strong>
    <label> </label>
    <label> </label>
  </p>
  <p>
    <label>
    <input type="submit" name="Submit" value="Delete Broadcasters" onclick="toserver(this.form); return false; " />
    </label>
  </p>
</form>
</body>
</html>
